package com.jack.design_patterns.creational.single;

/**
 * 懒汉式单例-同步代码块
 *  优点：解决了线程同步的问题
 *  缺点：效率比较低效
 */
public class SynchronizeCodeBlockLazySingleton {

    private static SynchronizeCodeBlockLazySingleton INSTANCE;

    private SynchronizeCodeBlockLazySingleton() {

    }

    public static SynchronizeCodeBlockLazySingleton getInstance() {
        if (INSTANCE == null) {
            synchronized (SynchronizeCodeBlockLazySingleton.class) {
                INSTANCE = new SynchronizeCodeBlockLazySingleton();
            }
        }
        return INSTANCE;
    }
}
